package com.ruoyi.web.controller.course;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.siyun.domain.SyCourseVideo;
import com.ruoyi.siyun.service.ISyCourseVideoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 课程视频管理Controller
 * 
 * @author CX330
 * @date 2024-12-25
 */
@RestController
@RequestMapping("/siyun/video")
public class SyCourseVideoController extends BaseController
{
    @Autowired
    private ISyCourseVideoService syCourseVideoService;

    /**
     * 查询课程视频管理列表
     */
    @PreAuthorize("@ss.hasPermi('siyun:video:list')")
    @GetMapping("/list")
    public AjaxResult list(SyCourseVideo syCourseVideo){
        List<SyCourseVideo> list = syCourseVideoService.selectSyCourseVideoList(syCourseVideo);
        return success(list);
    }

    /**
     * 导出课程视频管理列表
     */
    @PreAuthorize("@ss.hasPermi('siyun:video:export')")
    @Log(title = "课程视频管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SyCourseVideo syCourseVideo)
    {
        List<SyCourseVideo> list = syCourseVideoService.selectSyCourseVideoList(syCourseVideo);
        ExcelUtil<SyCourseVideo> util = new ExcelUtil<SyCourseVideo>(SyCourseVideo.class);
        util.exportExcel(response, list, "课程视频管理数据");
    }

    /**
     * 获取课程视频管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('siyun:video:query')")
    @GetMapping(value = "/{videoId}")
    public AjaxResult getInfo(@PathVariable("videoId") Long videoId)
    {
        return success(syCourseVideoService.selectSyCourseVideoByVideoId(videoId));
    }

    /**
     * 新增课程视频管理
     */
    @PreAuthorize("@ss.hasPermi('siyun:video:add')")
    @Log(title = "课程视频管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SyCourseVideo syCourseVideo)
    {
        return toAjax(syCourseVideoService.insertSyCourseVideo(syCourseVideo));
    }

    /**
     * 修改课程视频管理
     */
    @PreAuthorize("@ss.hasPermi('siyun:video:edit')")
    @Log(title = "课程视频管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SyCourseVideo syCourseVideo)
    {
        return toAjax(syCourseVideoService.updateSyCourseVideo(syCourseVideo));
    }

    /**
     * 删除课程视频管理
     */
    @PreAuthorize("@ss.hasPermi('siyun:video:remove')")
    @Log(title = "课程视频管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{videoIds}")
    public AjaxResult remove(@PathVariable Long[] videoIds)
    {
        return toAjax(syCourseVideoService.deleteSyCourseVideoByVideoIds(videoIds));
    }
}
